﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPF
{
    /// <summary>
    /// PopWindow
    /// </summary>
    public partial class PopWindow : Window
    {
        private PopWindow()
        {
            InitializeComponent();
            this.MouseDown += new MouseButtonEventHandler(PopWindow_MouseDown);
            this.Left = SystemParameters.WorkArea.Width - this.Width;
            this.Top = SystemParameters.WorkArea.Height - this.Height;
            btn_Close.Click += new RoutedEventHandler(btn_Close_Click);
        }
        private static PopWindow instance;
        /// <summary>
        /// 弹出消息框
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="ico">标题图片地址 【/名称空间;component/ico.ico】</param>
        /// <param name="content">显示内容</param>
        public static void PopInstance(string title, string ico, string content)
        {
            //  if (instance == null)
            instance = new PopWindow();
            instance.Title = title;
            instance.Icoimg = new BitmapImage(new Uri(ico, UriKind.RelativeOrAbsolute));
            instance.Content = content;
            instance.Show();
            // return instance;
                 
        }
        public static void PopAddContent(string newcontent)
        {
            instance.Content += newcontent;
        }
        public static void ClearContent()
        {
            instance.Content = string.Empty;
        }
        void btn_Close_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        void PopWindow_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                DragMove();
            }
        }

        public string Title { get { return txt_Title.Text; } set { txt_Title.Text = value; } }
        public ImageSource Icoimg { get { return imgico.Source; } set { imgico.Source = value; } }
        public string Content { get { return txt_content.Text; } set { txt_content.Text = value; } }
    }
}
